/*
 * Created on Feb 13, 2005
 * Created by dfhuynh
 */
package edu.mit.simile.longwell.query.compare;

import edu.mit.simile.longwell.Profile;

/**
 * @author dfhuynh
 */
public class IntegerComparator extends ComparatorBase {

	/**
	 * @param profile
	 * @param parameter
	 * @param locale
	 */
	public IntegerComparator(Profile profile, String parameter) {
		super(profile, parameter);
	}
	
	/* (non-Javadoc)
	 * @see edu.mit.simile.longwell.query.compare.IComparator#preprocess(java.lang.Object, java.lang.String)
	 */
	public Object preprocess(Object value, String locale) {
		return value;
	}

	/* (non-Javadoc)
	 * @see edu.mit.simile.longwell.query.compare.ComparatorBase#internalCompareAscending(java.lang.Object, java.lang.Object, java.lang.String)
	 */
	protected int internalCompareAscending(Object v1, Object v2, String locale) {
		if (v1 == null) {
			return v2 == null ? 0 : -1;
		} else if (v2 == null) {
			return 1;
		} else {
			return ((Integer) v1).compareTo((Integer) v2);
		}
	}

}
